/*
Date:2021/4/13 16:21pm
key:按最小的那个字符串去匹配。
*/
class Solution {
public:
static bool Cmp(string&a,string&b)
{
    return a.size()<b.size()?1:0;
}
    string longestCommonPrefix(vector<string>& strs) {
        string s1="";
        if(strs.size()==0)
        {
            return s1;
        }
        string s2="LDC";
        for(string j:strs)
        {
            if(s2=="LDC")
            {
                s2=j;
            }
            else
            {
                if(j.size()<s2.size())
                {
                    s2=j;
                }
            }
        }
        int k=0;
        bool flag;
        for(int i=0;i<s2.size();i++)
        {
            
            for(string j:strs)
            {
                if(j[i]!=s2[i])
                {
                    return s1;
                }
            }
            s1+=strs[0][i];
        }

        return s1;
    }
};